/*!	brief The Lerp Object will return the the current position between 2 point at a given time	*/
Lerp	=	function(positionA, positionB)
{
	/********************************/
	/*			Properties			*/	
	/********************************/
	
		this.m_Clock;	/*!<	Clock initialized at Lerp start	*/
		
		this.m_PositionA;		/*!<	Start position		*/
		this.m_PositionB;		/*!< 	End position		*/
		
		this.m_Forward;			/*!< vector linking position B and A	*/
		
		
		this.m_Delta;		/*!< Time in wich the Point M must go from the point A to B		*/
		this.m_Velocity;	/*!< Speed at wich the Point M must reach the point B from A	*/
		this.m_Distance;	/*!< Distance between A and B									*/
		
		this.m_End;			/*!< Flag used to know if the lerp finished it's movement		*/
		
		
	/********************************/
	/*			Constructor			*/	
	/********************************/
	
	this.m_End=true;
	this.m_Clock = new Clock();
	
	
}

Lerp.prototype.Init	=	function(positionA, positionB)
{
		this.m_PositionA= positionA;
		this.m_PositionB= positionB;
		

		
		this.m_Forward = this.m_PositionB.Minus(this.m_PositionA);
		
		this.m_Distance = this.m_Forward.Length();
		


}
Lerp.prototype.StartTime	=	function(time, positionA, positionB)
{
	this.Init(positionA, positionB);
	this.m_Delta=time;
	this.m_End=false;
	this.m_Clock.Start();
}

Lerp.prototype.StartVelocity	=	function( velocity, positionA, positionB)
{

	this.Init(positionA, positionB);
	this.m_Velocity		=velocity;
	this.m_Delta		=  this.m_Distance / this.m_Velocity;
	this.m_End=false;
	console.log("m_Delta " + (this.m_Delta));

	this.m_Clock.Start();
}

Lerp.prototype.Update			=	function()
{
	if(this.m_Clock.TimeElapsed() > this.m_Delta)
	{
		console.log("Forward " + (this.m_PositionA.Plus(this.m_Forward)).x);
		this.m_End=true;
		return (this.m_PositionA.Plus(this.m_Forward)) ;
	}
	else
	{
		return this.m_PositionA.Plus(this.m_Forward.MultScalaire((this.m_Clock.TimeElapsed()/this.m_Delta)));
	}
}
